﻿/*
 * Copyright 2009 José David Tuero Rodríguez

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 * */
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace AtmosCreator
{
    /// <summary>
    /// Main form
    /// </summary>
    public partial class FrmMain : Form
    {
        /// <summary>
        /// Localizer
        /// </summary>
        Localizer _localizer;

        /// <summary>
        /// Game selected
        /// </summary>
        string _gameSelected;


        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="localizer">Localizer</param>
        public FrmMain(Localizer localizer)
        {
            InitializeComponent();
            localizer.LocalizeForm(this);
            _localizer = localizer;            
            FrmSelectGame select = new FrmSelectGame(this, _localizer);
            select.Show();
        }

      

        /// <summary>
        /// Menu selection
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void playToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                this.Visible = false;
                FrmPlay play = new FrmPlay(this,_localizer,_gameSelected);
                play.Show();
            }
            catch (Exception)
            {

            }
        }

        /// <summary>
        /// Menu selection
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void tutorialToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            FrmTutorial play = new FrmTutorial(this,_localizer);
            play.Show();
        }

        /// <summary>
        /// Menu selection
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void aboutAtmosCreatorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            FrmAbout about = new FrmAbout(this);
            about.Show();
        }

        /// <summary>
        /// Menu selection
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void settingsStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            FrmConf conf = new FrmConf(this, _localizer,_gameSelected);
            conf.Show();
        }

        /// <summary>
        /// Menu selection
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void languageToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Visible = false;
            FrmLanguage lang = new FrmLanguage(this,_localizer);
            lang.Show();
        }

        /// <summary>
        /// Sets the localizer of the form
        /// </summary>
        /// <param name="localizer">Localizer to set</param>
        public void SetLocalizer(Localizer localizer)
        {
            _localizer = localizer;
            _localizer.LocalizeForm(this);
        }


        /// <summary>
        /// When showed first time load make it no visible so select game is the only form visible
        /// </summary>
        /// <param name="sender">sender</param>
        /// <param name="e">e</param>
        private void FrmMain_Shown(object sender, EventArgs e)
        {
            this.Visible = false;
        }

        /// <summary>
        /// get and set methods
        /// </summary>
        public string GameSelected
        {
            set
            {
                _gameSelected = value;
            }
        }

    }
}
